import React from "react"
import "../../styles/sty/order.css"
import { Link} from "react-router-dom"
import {getOrder}  from "../../api/index_y"
// import { Route, BrowserRouter as Router ,Link} from "react-router-dom"


class order extends React.Component{
    constructor(params) {
       super()
       this.state={

        list:[],
        users:"",

       }
    }
            

    componentDidMount(){

        let  go=localStorage.getItem("token")
        // console.log(go)
       
          if(go==""){
            this.setState({
                list:[1]
            })
           
              
          }else if(go!=""){
           this.setState({
               list:[]
           })
            getOrder(this.state).then(res=>{
                console.log(res.data)
                this.setState({
                    list:res.data
                })
            })
        }

 }
    render(h) {
           let { list }=this.state
        return(
<<<<<<< HEAD
<div className="yxl7">
=======
<div>
>>>>>>> 90970c75563bd55771150ee58505cae3aacce616
            
              <div id="header">
              <Link  to='/App'><div id="headPic"></div></Link>
                  <h3> 订单列表</h3>
 </div>
                <ul id="ul5">
                    
                     {list.map(({ restaurant_image_url,restaurant_name,formatted_created_at })=>{
                            return (
                            <li>
                                <img src={"https://elm.cangdu.org/img/"+restaurant_image_url} alt="请登录" />
                                <b>{ restaurant_name }</b>
<<<<<<< HEAD
                                 <i>订单已送达</i>
                                <p id="_p2">{formatted_created_at}</p>
                               
=======
                                <p id="_p2">{formatted_created_at}</p>
>>>>>>> 90970c75563bd55771150ee58505cae3aacce616
                            </li>
                            )
                        })}
                        
                    </ul>
<<<<<<< HEAD
=======
            <div id="footer"></div>
>>>>>>> 90970c75563bd55771150ee58505cae3aacce616
 </div>  
        )
    }
}
 



export default order